/*
 * read_config_xml.cpp
 *
 *  Created on: Mar 31, 2010
 *      Author: root
 */
#include "read_config_xml.hpp"

bool control_center::read_config_xml(void)
{
	    const char* str;
	    CConfig xmlConfig("/opt/Programe/Cctv_Control_System_new/src/config.xml");

	    TiXmlElement* firstChild=0;
	    TiXmlElement* SecendChild=0;
	    TiXmlElement* Thechiled=0;

	    //read keyboard'setup.
		INIT_LIST_HEAD(&keyboard_list);
	    t_keyboard *Cctv_p_keyboard;
	    firstChild=xmlConfig.GetElemofromboot("keyboard");
	    if (firstChild)
	    {
	       for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	       {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"keyboard")==0)
	    	    {
	        	   Cctv_p_keyboard = new t_keyboard;

	        	   Cctv_p_keyboard->pkeyboard = new c_keyboard(CONVTEXT(SecendChild,"id"),
	        			   xmlConfig.tconvtext_(SecendChild,"name") ,CONVTEXT(SecendChild,"led_show"),CONVTEXT(SecendChild,"showtype"),CONVTEXT(SecendChild,"defaultuser"),CONVTEXT(SecendChild,"defaultmonitor"),CONVTEXT(SecendChild,"maxspeed"));  //class new.
	               for (Thechiled=SecendChild->FirstChildElement();Thechiled;Thechiled=Thechiled->NextSiblingElement())
	               {
	                   str=Thechiled->Value();
	                   if (str==NULL) continue;
	                   if (strcmp(str,"comm_port")==0)
	                   {
	                	   //call add port.
	                	   str = Thechiled->GetText();
	                	   if (str)
	                	   Cctv_p_keyboard->pkeyboard->add_port(strtoul(str,'\0',10));
	                   }
	               }
	        	   list_add( &(Cctv_p_keyboard->list), &keyboard_list);
	    	    };

	       }
	    }

	    /*
	  	struct list_head *pos;
		t_keyboard *temp;
	 	list_for_each(pos,&keyboard_list)
	 	{
	 		temp = list_entry(pos,struct t_keyboard,list);
	 		temp->pkeyboard->showid();
	 		delete(temp->pkeyboard);
	 		delete(temp);
	 	}
	   */



	    //read camera_list
		INIT_LIST_HEAD(&camera_list);
		t_matrix_input * matrix_input;
	    firstChild=xmlConfig.GetElemofromboot("matrix_input");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"camera")==0)
	    	    {
	    	        matrix_input = new t_matrix_input;
	    	        matrix_input->id=CONVTEXT(SecendChild,"id");
	    	        memset(matrix_input->name,0x0,NAME_LENIGHT);
	    	        memcpy(matrix_input->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
	    	        matrix_input->inttype=(matrix_int_type)CONVTEXT(SecendChild,"inttype");
	    	        matrix_input->firstmatrixno=CONVTEXT(SecendChild,"firstmatrixno");
	    	        matrix_input->firstslot=CONVTEXT(SecendChild,"firstslot");
	    	        matrix_input->firstport=CONVTEXT(SecendChild,"firstport");
	    	        matrix_input->sencondmatrixno=CONVTEXT(SecendChild,"sencondmatrixno");
	    	        matrix_input->sencondslot=CONVTEXT(SecendChild,"sencondslot");
	    	        matrix_input->sencondport=CONVTEXT(SecendChild,"sencondport");
	    	        matrix_input->matrixid=CONVTEXT(SecendChild,"matrixid");
	    	        matrix_input->input_no=CONVTEXT(SecendChild,"input_no");
			        list_add( &(matrix_input->list), &camera_list);
			        my_printf("add camera: id=%d name=%s input_no=%d, inttype=%d,firstmatrino=%d,firstslot=%d,firstport=%d,sencondmatrixno=%d,sencondslot=%d,sencondport=%d,matrixid=%d\n",
			        		matrix_input->id,matrix_input->name,matrix_input->input_no,matrix_input->inttype,matrix_input->firstmatrixno,matrix_input->firstslot,matrix_input->firstport,
			        		matrix_input->sencondmatrixno,matrix_input->sencondslot,matrix_input->sencondport,matrix_input->matrixid);
	    	    }
	        }
	    }


	    //read monitor_list
		INIT_LIST_HEAD(&monitor_list);
		t_matrix_output * matrix_output;
	    firstChild=xmlConfig.GetElemofromboot("matrix_output");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"monitor")==0)
	    	    {
	    	    	matrix_output = new t_matrix_output;
	    	    	matrix_output->id=CONVTEXT(SecendChild,"id");
	    	    	memset(matrix_output->name,0x0,NAME_LENIGHT);
	    	        memcpy(matrix_output->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
	    	        matrix_output->outtype=(matrix_out_type)CONVTEXT(SecendChild,"outtype");
	    	        matrix_output->matrixno=CONVTEXT(SecendChild,"matrixno");
	    	        matrix_output->slot=CONVTEXT(SecendChild,"slot");
	    	        matrix_output->port=CONVTEXT(SecendChild,"port");
	    	        matrix_output->matrixid=CONVTEXT(SecendChild,"matrixid");
	    	        matrix_output->output_no=CONVTEXT(SecendChild,"output_no");
			        list_add( &(matrix_output->list), &monitor_list);
			        my_printf("add monitor: id=%d name=%s output_no=%d outtype=%d,matrixno=%d,slot=%d,port=%d,matrixid=%d\n",
			        		matrix_output->id,matrix_output->name,matrix_output->output_no,matrix_output->outtype,matrix_output->matrixno,matrix_output->slot,matrix_output->port,matrix_output->matrixid);
	    	    }
	        }
	    }
	    //read matrix_list
		INIT_LIST_HEAD(&matrix_list);
		t_matrix * matrix;
	    firstChild=xmlConfig.GetElemofromboot("matrix");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"matrix")==0)
	    	    {
	    	    	matrix = new t_matrix;
	    	    	matrix->id=CONVTEXT(SecendChild,"id");
	    	    	memset(matrix->name,0x0,NAME_LENIGHT);
	    	        memcpy(matrix->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
	    	        matrix->max_input=CONVTEXT(SecendChild,"max_input");
	    	        matrix->max_output=CONVTEXT(SecendChild,"max_output");
	    	        INIT_LIST_HEAD(&matrix->Comm_list);
	                for (Thechiled=SecendChild->FirstChildElement();Thechiled;Thechiled=Thechiled->NextSiblingElement())
	                {
	                    str=Thechiled->Value();
	                    if (str==NULL) continue;
	                    if (strcmp(str,"comm_port")==0)
	                    {
	                 	   //call add port.
	                 	   str = Thechiled->GetText();
	                 	   if (str)
	                 	   {
	                 		t_commlist* comm_list;
	                 		comm_list = new t_commlist;
	                 		comm_list->commmid=strtoul(str,'\0',10);
	                 		list_add( &(comm_list->list), &matrix->Comm_list);
	                 		my_printf("matrix  %d add commport %d\n",matrix->id,comm_list->commmid);
	                 	   }
	                    }
	                }
			        list_add( &(matrix->list), &matrix_list);
			        my_printf("add matrix: id=%d name=%s max_input=%d,max_output=%d\n",
			        		matrix->id,matrix->name,matrix->max_input,matrix->max_output);
	    	    }
	        }
	    }



	    //read camerar_control_list
		INIT_LIST_HEAD(&camerar_control_list);
		t_camera_control * camera_control;
	    firstChild=xmlConfig.GetElemofromboot("camera_control");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"camera_control")==0)
	    	    {
	    	    	camera_control = new t_camera_control;
	    	    	camera_control->id=CONVTEXT(SecendChild,"id");
	    	    	camera_control->camera_id=CONVTEXT(SecendChild,"camera_id");
	    	    	camera_control->ctrol_matrix=CONVTEXT(SecendChild,"ctrol_matrix");
	    	    	camera_control->ctrol_slot=CONVTEXT(SecendChild,"ctrol_slot");
	    	    	camera_control->ctrol_port=CONVTEXT(SecendChild,"ctrol_port");
	    	    	camera_control->auto_pretest=CONVTEXT(SecendChild,"auto_pretest");
	    	        INIT_LIST_HEAD(&camera_control->Comm_list);
	                for (Thechiled=SecendChild->FirstChildElement();Thechiled;Thechiled=Thechiled->NextSiblingElement())
	                {
	                    str=Thechiled->Value();
	                    if (str==NULL) continue;
	                    if (strcmp(str,"comm_port")==0)
	                    {
	                 	   //call add port.
	                 	   str = Thechiled->GetText();
	                 	   if (str)
	                 	   {
	                 		t_commlist* comm_list;
	                 		comm_list = new t_commlist;
	                 		comm_list->commmid=strtoul(str,'\0',10);
	                 		list_add( &(comm_list->list), &camera_control->Comm_list);
	                 		my_printf("camera control %d add commport %d\n",camera_control->id,comm_list->commmid);
	                 	   }
	                    }
	                }
			        list_add( &(camera_control->list), &camerar_control_list);
			        my_printf("add camera_control: id=%d camera_id=%d ctrol_matrix=%d,ctrol_slot=%d,ctrol_port=%d,auto_pretest=%d\n",
			        		camera_control->id,camera_control->camera_id,camera_control->ctrol_matrix,camera_control->ctrol_slot,camera_control->ctrol_port,camera_control->auto_pretest);
	    	    }
	        }
	    }


	    //read camerar_control_exchange_list
		INIT_LIST_HEAD(&camerar_control_exchange_list);
		t_camera_control_exchange * camera_control_exchange;
	    firstChild=xmlConfig.GetElemofromboot("control_exchange");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"exchange")==0)
	    	    {
	    	    	camera_control_exchange = new t_camera_control_exchange;
	    	    	camera_control_exchange->id=CONVTEXT(SecendChild,"id");
	    	    	camera_control_exchange->from=(camera_control_switch_cmd)CONVTEXT(SecendChild,"from");
	    	    	camera_control_exchange->camera_control_id=CONVTEXT(SecendChild,"camera_control_id");
	    	    	camera_control_exchange->to=(camera_control_switch_cmd)CONVTEXT(SecendChild,"to");

			        list_add( &(camera_control_exchange->list), &camerar_control_exchange_list);
			        my_printf("add camera control exchange : id=%d camera_control_id=%d,from=%d,to=%d\n",
			        		camera_control_exchange->id,camera_control_exchange->camera_control_id,camera_control_exchange->from,camera_control_exchange->to);
	    	    }
	        }
	    }
	    //read osd_list
		INIT_LIST_HEAD(&osd_list);
		t_osd * osd;
	    firstChild=xmlConfig.GetElemofromboot("osd");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"osd")==0)
	    	    {
	    	    	osd = new t_osd;
	    	    	osd->id=CONVTEXT(SecendChild,"id");
	    	    	memset(osd->name,0x0,NAME_LENIGHT);
	    	        memcpy(osd->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
	    	        osd->linkdevice=(osd_link_device)CONVTEXT(SecendChild,"linkdevice");
	    	        osd->linkport=CONVTEXT(SecendChild,"linkport");
	    	        osd->matrixno=CONVTEXT(SecendChild,"matrixno");
	    	        osd->slotno=CONVTEXT(SecendChild,"slotno");
	    	        osd->port=CONVTEXT(SecendChild,"port");
	    	        osd->inist=CONVTEXT(SecendChild,"inist");
	    	        osd->defaultx=CONVTEXT(SecendChild,"defaultx");
	    	        osd->defaulty=CONVTEXT(SecendChild,"defaulty");
	    	        INIT_LIST_HEAD(&osd->Comm_list);
	                for (Thechiled=SecendChild->FirstChildElement();Thechiled;Thechiled=Thechiled->NextSiblingElement())
	                {
	                    str=Thechiled->Value();
	                    if (str==NULL) continue;
	                    if (strcmp(str,"comm_port")==0)
	                    {
	                 	   //call add port.
	                 	   str = Thechiled->GetText();
	                 	   if (str)
	                 	   {
	                 		t_commlist* comm_list;
	                 		comm_list = new t_commlist;
	                 		comm_list->commmid=strtoul(str,'\0',10);
	                 		list_add( &(comm_list->list), &osd->Comm_list);
	                 		my_printf("osd  %d add commport %d\n",osd->id,comm_list->commmid);
	                 	   }
	                    }
	                }
			        list_add( &(osd->list), &osd_list);
			        my_printf("add osd: id=%d name=%s linkdevice=%d,linkport=%d,matrixno=%d,slotno=%d,port=%d,inist=%d,defaultx=%d,defaulty=%d\n",
			        		osd->id,osd->name,osd->linkdevice,osd->linkport,osd->matrixno,osd->slotno,osd->port,osd->inist,osd->defaultx,osd->defaulty);
	    	    }
	        }
	    }


	    //read osd_showtype_list
		INIT_LIST_HEAD(&osd_show_list);
		t_osd_show_list * osd_show;
	    firstChild=xmlConfig.GetElemofromboot("osdshow");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"osdshow")==0)
	    	    {
	    	    	osd_show = new t_osd_show_list;
	    	    	osd_show->id=CONVTEXT(SecendChild,"id");
	    	    	osd_show->showtype=(osd_show_type)CONVTEXT(SecendChild,"showtype");
	    	    	osd_show->show_x=CONVTEXT(SecendChild,"show_x");
	    	    	osd_show->show_y=CONVTEXT(SecendChild,"show_y");
	    	    	osd_show->show_stop_time=CONVTEXT(SecendChild,"show_stop_time");
	    	    	memset(osd_show->const_str,0x0,SHOW_OSD_MAX);
	    	        memcpy(osd_show->const_str,xmlConfig.tconvtext_(SecendChild,"const_str"),SHOW_OSD_MAX-1);
			        list_add( &(osd_show->list), &osd_show_list);
			        my_printf("add osd show  : id=%d showtype=%d,show_x=%d,show_y=%d,show_stop_time=%d,const_str=%s\n",
			        		osd_show->id,osd_show->showtype,osd_show->show_x,osd_show->show_y,osd_show->show_stop_time,osd_show->const_str);
	    	    }
	        }
	    }


	    //read commport_list
		INIT_LIST_HEAD(&commport_list);
		t_commport * commport;
	    firstChild=xmlConfig.GetElemofromboot("commport");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"commport")==0)
	    	    {
	    	    	commport = new t_commport;
	    	    	commport->id=CONVTEXT(SecendChild,"id");
	    	    	memset(commport->name,0x0,NAME_LENIGHT);
	    	        memcpy(commport->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
	    	        commport->commtype=(comm_type)CONVTEXT(SecendChild,"commtype");
	    	    	memset(commport->port_path,0x0,URL_LENGTH);
	    	        memcpy(commport->port_path,xmlConfig.tconvtext_(SecendChild,"port_path"),URL_LENGTH-1);
	    	        commport->port=CONVTEXT(SecendChild,"port");
	    	        commport->data=CONVTEXT(SecendChild,"data");
	    	        commport->chk_data=CONVTEXT(SecendChild,"chk_data");
	    	        commport->sotp_bit=CONVTEXT(SecendChild,"sotp_bit");
			        list_add( &(commport->list), &commport_list);
			        my_printf("add commport : id=%d name=%s,commtype=%d,port_path=%s,data=%d,chk_data=%d,sotp_bit=%d\n",
			        		commport->id,commport->name,commport->commtype,commport->port_path,commport->port,commport->data,commport->chk_data,commport->sotp_bit);
	    	    }
	        }
	    }


	    //read gateway_list
		INIT_LIST_HEAD(&gateway_list);
		t_gateway * gateway;
	    firstChild=xmlConfig.GetElemofromboot("gateway");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"gateway")==0)
	    	    {
	    	    	gateway = new t_gateway;
	    	    	gateway->id=CONVTEXT(SecendChild,"id");
	    	    	memset(gateway->name,0x0,NAME_LENIGHT);
	    	        memcpy(gateway->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
	    	        gateway->my_node=(comm_type)CONVTEXT(SecendChild,"my_node");
	    	        gateway->remoter_node=CONVTEXT(SecendChild,"remoter_node");
	    	        gateway->commport_id=CONVTEXT(SecendChild,"commport_id");
			        list_add( &(gateway->list), &gateway_list);
			        my_printf("add gateway : id=%d name=%s,my_node=%d,remoter_node=%d,commport_id=%d\n",
			        		gateway->id,gateway->name,gateway->my_node,gateway->remoter_node,gateway->commport_id);
	    	    }
	        }
	    }
	    //read scan_list
		INIT_LIST_HEAD(&scan_list);
		t_scan * scan;
	    firstChild=xmlConfig.GetElemofromboot("scan");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"scan")==0)
	    	    {
	    	    	scan = new t_scan;
	    	    	scan->id=CONVTEXT(SecendChild,"id");
	    	    	memset(scan->name,0x0,NAME_LENIGHT);
	    	        memcpy(scan->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
	    	        scan->scan_no=CONVTEXT(SecendChild,"scan_no");
	    	        scan->waittime=CONVTEXT(SecendChild,"waittime");
	    	        INIT_LIST_HEAD(&scan->camera_list);
	                for (Thechiled=SecendChild->FirstChildElement();Thechiled;Thechiled=Thechiled->NextSiblingElement())
	                {
	                    str=Thechiled->Value();
	                    if (str==NULL) continue;
	                    if (strcmp(str,"camera")==0)
	                    {
	                 	   //call add port.
	                 	   str = Thechiled->GetText();
	                 	   if (str)
	                 	   {
	                 		t_commlist* comm_list;
	                 		comm_list = new t_commlist;
	                 		comm_list->commmid=strtoul(str,'\0',10);
	                 		list_add( &(comm_list->list), &scan->camera_list);
	                 		my_printf("scan  %d add camera %d\n",osd->id,comm_list->commmid);
	                 	   }
	                    }
	                }
			        list_add( &(scan->list), &scan_list);
			        my_printf("add scan : id=%d,name=%s,scan_no=%d,waittime=%d\n",
			        		scan->id,scan->name,scan->scan_no,scan->waittime);
	    	    }
	        }
	    }
	    //read mrico_list
		INIT_LIST_HEAD(&macro_list);
		t_macro *macro;
	    firstChild=xmlConfig.GetElemofromboot("macro");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"macro")==0)
	    	    {
	    	    	macro = new t_macro;
	    	    	macro->id=CONVTEXT(SecendChild,"id");
	    	    	memset(macro->name,0x0,NAME_LENIGHT);
	    	        memcpy(macro->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
			        list_add( &(macro->list), &macro_list);
			        my_printf("add micro: id=%d name=%s\n",
			        		macro->id,macro->name);
	    	    }
	        }
	    }

	    //read mrico_COMMAND_list
		INIT_LIST_HEAD(&macro_command_list);
		t_macro_command *macro_command;
	    firstChild=xmlConfig.GetElemofromboot("microcommand");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"microcommand")==0)
	    	    {
	    	    	macro_command = new t_macro_command;
	    	    	macro_command->id=CONVTEXT(SecendChild,"id");
	      	    	macro_command->macroid=CONVTEXT(SecendChild,"macroid");
	      	    	macro_command->command=CONVTEXT(SecendChild,"command");
	      	    	macro_command->parameter1=CONVTEXT(SecendChild,"parameter1");
	      	    	macro_command->parameter2=CONVTEXT(SecendChild,"parameter2");
	      	    	macro_command->parameter3=CONVTEXT(SecendChild,"parameter3");
			        list_add( &(macro_command->list), &macro_command_list);
			        my_printf("add micro_command: id=%d,macroid=%d,command=%d,parameter1=%d,parameter2=%d,parameter3=%d\n",
			        		macro_command->id,macro_command->macroid,macro_command->command,macro_command->parameter1,macro_command->parameter2,macro_command->parameter3);
	    	    }
	        }
	    }


		INIT_LIST_HEAD(&user_list);
		t_user *user;
	    firstChild=xmlConfig.GetElemofromboot("user");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"user")==0)
	    	    {
	    	    	user = new t_user;
	    	    	user->id=CONVTEXT(SecendChild,"id");
	    	    	memset(user->name,0x0,NAME_LENIGHT);
	    	        memcpy(user->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
	    	    	memset(user->password,0x0,NAME_LENIGHT);
	    	        memcpy(user->password,xmlConfig.tconvtext_(SecendChild,"password"),NAME_LENIGHT-1);
	    	        user->groupid=CONVTEXT(SecendChild,"groupid");
			        list_add( &(user->list), &user_list);
			        my_printf("add user: id=%d name=%s,passowrd=%s,groupid=%d\n",
			        		user->id,user->name,user->password,user->groupid);
	    	    }
	        }
	    }

		INIT_LIST_HEAD(&usergroup_list);
		t_usergroup *usergroup;
	    firstChild=xmlConfig.GetElemofromboot("usrgroup");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"usrgroup")==0)
	    	    {
	    	    	usergroup = new t_usergroup;
	    	    	usergroup->id=CONVTEXT(SecendChild,"id");
	    	    	usergroup->level=CONVTEXT(SecendChild,"level");
	    	    	memset(usergroup->name,0x0,NAME_LENIGHT);
	    	        memcpy(usergroup->name,xmlConfig.tconvtext_(SecendChild,"name"),NAME_LENIGHT-1);
			        list_add( &(usergroup->list), &usergroup_list);
			        my_printf("add usergroup: id=%d name=%s,level=%d\n",
			        		usergroup->id,usergroup->name,usergroup->level);
	    	    }
	        }
	    }

		INIT_LIST_HEAD(&groupaccess_list);
		t_groupaccess *groupaccess;
	    firstChild=xmlConfig.GetElemofromboot("groupaccess");
	    if (firstChild)
	    {
	        for (SecendChild=firstChild->FirstChildElement();SecendChild;SecendChild=SecendChild->NextSiblingElement())
	        {
	    	    str=SecendChild->Value();
	    	    if (str==NULL) continue;
	    	    if (strcmp(str,"groupaccess")==0)
	    	    {
	    	    	groupaccess = new t_groupaccess;
	    	    	groupaccess->id=CONVTEXT(SecendChild,"id");
	    	    	groupaccess->groupid=CONVTEXT(SecendChild,"groupid");
	    	    	groupaccess->itemid=CONVTEXT(SecendChild,"itemid");
	    	    	groupaccess->access=CONVTEXT(SecendChild,"access");
			        list_add( &(groupaccess->list), &groupaccess_list);
			        my_printf("add group access: id=%d ,groupid=%d ,itemid=%d ,access=%d\n",
			        		groupaccess->id,groupaccess->groupid,groupaccess->itemid,groupaccess->access);
	    	    }
	        }
	    }
	   return true;
}


control_center::~control_center()
{
  my_printf("Control start free\n");

}
